package com.study.jbm;

import java.util.Arrays;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.study.jbm.calculate.Calculator;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    { 
    	ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:context/common.xml");
    	System.out.println(Arrays.toString(context.getBeanDefinitionNames()));
    	Calculator cal = (Calculator) context.getBean("calculator");
    	
    	int[] a = new int[args.length];
    	StringBuilder buffer = new StringBuilder();
    	for(int i=0; i<args.length; i++) {
    		a[i] = Integer.parseInt(args[i]);
    		buffer.append(a[i]).append(" +");
    	}
    	String sy = buffer.substring(0, buffer.length()-1);
    	sy = sy + "= " + cal.calc(a);
    	System.out.println(sy);
    	
    }
}
